<?php

use App\Http\Controllers\BookController;
use App\Http\Controllers\SpiderController;
use App\Http\Controllers\SplitWordsController;
use App\Models\Book;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Route;


/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});

Route::get('books', [BookController::class, 'getBooks']);

Route::get('book', [BookController::class, 'getBook']);

Route::post('crawl', [SpiderController::class, 'create']);

Route::post('cancel_spider', [SpiderController::class, 'cancel']);

Route::get('spiders', [SpiderController::class, 'getAll']);

Route::get('spiders_by_key', [SpiderController::class, 'getSpidersByKey']);

Route::get('keys', [SpiderController::class, 'getKeys']);

Route::get('split', [SplitWordsController::class, 'index']);

Route::get('get_stopwords', [SplitWordsController::class, 'getStopWords']);

Route::post('search', [BookController::class, 'databaseSearch']);

Route::post('search_statistics', [BookController::class, 'searchStatistics']);

Route::get('comments', [
    \App\Http\Controllers\CommentController::class, 'index'
]);

Route::get('word_cloud', [
    \App\Http\Controllers\WordCloudController::class, 'index'
]);

Route::get('product_info', [
    BookController::class, 'getProductInfo'
]);
